<?php

require_once 'CObject.php';
require_once 'StringKit/CEncoding.php';

class CString extends CObject {
	function AsBuffer($encoding, $allowLoss = null) {
		$enc = &CEncoderCreateOfEncoding($encoding, $allowLoss);
		$enc->AppendString($this);
		return $enc->AsBuffer();
	}
	
	function AsOutputBuffer($allowLoss = null) {
		return $this->AsBuffer(CEncodingGetOutput(), $allowLoss);
	}
	
	function __toString() { return $this->AsOutputBuffer(); }
		
	function &Characters($from, $len) {
		CAbstract('CString::Characters()', $this);
	}
	
	function &AllCharacters() {
		$x = &$this->Characters(0, $this->Length());
		return $x;
	}
	
	function Length() {
		CAbstract('CString::Length()', $this);
	}
	
	function MakeNewFromBuffer($buf) {
		CAbstract('CString::MakeNewFromBuffer()', $this);
	}
	
	function Substring($from, $len) {
		return new CStringSlice($this, $from, $len);
	}
	
	function Appending(/* ... */) {
		$args = func_get_args();
		array_splice($args, 0, 0, array($this));
		return new CStringChain($args);
	}
	
	function Prepending(/* ... */) {
		$args = func_get_args();
		$args[] = $this;
		return new CStringChain($args);
	}
	
	function FastBufferOfEncoding($encoding) {
		return null;
	}
}

class CCharIterator extends CObject {	
	function NextChar() {
		CAbstract('CCharIterator::NextChar()', $this);
	}
}

?>